<template>
  <page-body>
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center information_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub information_fd0_0'>
          <view class='flex flex-wrap align-center information_fd0_0_c0' @tap.stop="goHome" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  information_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <!-- <text class='information_fd0_0_c1_c0'>完善资料</text> -->
          </view>
          <view class='flex flex-wrap align-center justify-end information_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout information_flex_1">
        <text class='information_fd1_0'>请完善个人信息</text>
        <view class='flex flex-wrap align-center information_fd1_1'>
          <benben-image-upload :path.sync="dataDetails.avatar" :img-id.sync="dataDetails.avatar" :is-cropping="true"
            :is-show-clean="false" class="upload position-relative information_fd1_1_c0">

            <image class=" information_fd1_1_c0" mode="aspectFit"
              :src="dataDetails.avatar ? dataDetails.avatar : STATIC_URL+'186.png'"></image>
            <image class='information_fd1_1_c1' mode="aspectFit" :src='STATIC_URL+"153.png"'></image>
          </benben-image-upload>
          <!-- <image class='information_fd1_1_c0' mode="aspectFit" :src='STATIC_URL+"152.png"'></image> -->

        </view>
        <view class='flex flex-wrap align-center justify-between information_fd1_2'>
          <view class='flex flex-wrap align-center justify-around ' @click.stop="chooseSex('1')"
            :class="dataDetails.gender == '1' ? 'information_fd1_2_c0' : 'information_fd1_2_c1'">
            <image class='information_fd1_2_c0_c0' v-if="dataDetails.gender != '1'" mode="aspectFit"
              :src='STATIC_URL+"158.png"'></image>
            <!-- 选中 -->
            <image class='information_fd1_2_c0_c0' v-else mode="aspectFit" :src='STATIC_URL+"211.png"'></image>
            <text>男生</text>
          </view>
          <view class='flex flex-wrap align-center justify-around information_fd1_2_c1' @click.stop="chooseSex('2')"
            :class="dataDetails.gender == '2' ? 'information_fd1_2_c0 ' : 'information_fd1_2_c1'">
            <image class='information_fd1_2_c0_c0' v-if="dataDetails.gender != '2'" mode="aspectFit"
              :src='STATIC_URL+"157.png"'></image>
            <!-- 选中 -->
            <image class='information_fd1_2_c0_c0' v-else mode="aspectFit" :src='STATIC_URL+"210.png"'></image>
            <text>女生</text>
          </view>
        </view>
        <view class='flex flex-wrap align-center information_fd1_3'>
          <benben-input class='information_fd1_3_c0' type="text" :placeholder="`请输入昵称，最长8个字符`" confirm-type="done"
            :maxlength="8" :adjust-position='true' placeholder-style="color:#999;font-size:32rpx"
            v-model="dataDetails.nickname" />
        </view>
        <view class='flex flex-wrap align-center justify-between information_fd1_4'
          @tap.stop="pickerDiy1721095960213=true">
          <text>{{dataDetails.birthday || '请设置生日'}}</text>
          <image class='information_fd1_4_c1' mode="aspectFit" :src='STATIC_URL+"156.png"'></image>
        </view>
      </view>

      <!---flex布局flex布局结束-->
      <!--选择器开始 -->
      <benben-picker ref="benbenWritePickerCodepicker2" :visible.sync="pickerDiy1721095960213"
        :value.sync='dataDetails.birthday' end-year='现在' mode='date' :picker-height='88' :current='true'
        :mask-show='true' fields='day' :timeout='true' start-year='1990-01-01'>
        <template #picker-header>
          <view class='flex flex-wrap align-center justify-between information_picker2_0'>
            <text @tap="$refs.benbenWritePickerCodepicker2.cancel()">取消</text>
            <text>选择生日</text>
            <text class='information_picker2_0_c2' @tap="$refs.benbenWritePickerCodepicker2.pickerConfirm()">确认</text>
          </view>
        </template>
      </benben-picker>
      <!--选择器结束 -->
      <view class="flex benben-position-layout flex flex-wrap align-center information_flex_3"
        :style="{height:(200+bottomSafeAreaRpx)+'rpx',paddingBottom:bottomSafeAreaRpx+'rpx', }">
        <button class='information_fd3_0' @tap.stop="submit()">下一步</button>

      </view>
      <view :style="{height: (200+bottomSafeAreaRpx)+'rpx'}"></view>


    </view>
  </page-body>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        "pickerDiy1721095960213": false,
        dataDetails: ''
      };
    },
    computed: {

    },
    watch: {},
    onLoad(options) {
      this.getUserinfoFunc()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      goHome() {
        this.$urouter.switchTab(`/pages/tabBar/home/home`);
      },
      async submit() {

        let datadataMessage = await this.$api.dbPost(global.apiUrls.post5cb54af125f1c, {
          avatar: this.dataDetails.avatar,
          nickname: this.dataDetails.nickname,
          gender: this.dataDetails.gender,
          birthday: this.dataDetails.birthday,
        });
        if (!datadataMessage) return
        if (datadataMessage.data.code != 1) {
          this.$message.info(datadataMessage.data.msg);
          return
        }
        let infodataMessage = datadataMessage.data;
        this.dataMessage = infodataMessage.data

        setTimeout(() => {
          this.isCheck = false;
        }, 500)
        uni.$TIM.updateMyProfile({
          nick: this.dataDetails.nickname,
          avatar: this.dataDetails.avatar,
        }).then(() => {
          console.log('gengxin 成功')
        })
        setTimeout(() => {
          this.$urouter.switchTab(`/pages/tabBar/home/home`);
        }, 800)
      },
      chooseSex(type) {
        this.dataDetails.gender = type
      },
      //获取个人信息
      async getUserinfoFunc() {
        //请求方法
        //数据验证

        let datadataDetails = await this.$api.get(global.apiUrls.post5c78c4772da97, {

        });

        if (datadataDetails.data.code != 1) {
          this.$message.info(datadataDetails.data.msg);
          return
        }
        let infodataDetails = datadataDetails.data;
        this.dataDetails = infodataDetails.data

        // if (this.dataDetails.gender == '1') {
        //   this.sex = '男';
        // } else if (this.dataDetails.gender == '2') {
        //   this.sex = '女';
        // } else {
        //   this.sex = '保密';
        // }
      },
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .information_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .information_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .information_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .information_fd0_0_c0 {
    width: 120rpx;
  }

  .information_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .information_flex_1 {
    margin: 40rpx 0rpx 0rpx 0rpx;
  }

  .information_fd1_4_c1 {
    width: 32rpx;
    height: 32rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .information_fd1_4 {
    background: #F8F8F8;
    border-radius: 60rpx 60rpx 60rpx 60rpx;
    width: 638rpx;
    height: 110rpx;
    line-height: 110rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    font-size: 32rpx;
  }

  .information_fd1_3_c0 {
    height: 110rpx;
    line-height: 110rpx;
    width: 600rpx;
    font-size: 32rpx;
  }

  .information_fd1_3 {
    background: #F8F8F8;
    border-radius: 60rpx 60rpx 60rpx 60rpx;
    width: 638rpx;
    height: 110rpx;
    line-height: 110rpx;
    padding: 0rpx 24rpx 0rpx 24rpx;
    margin: 48rpx 0rpx 48rpx 0rpx;
  }

  .information_fd1_2_c1 {
    background: rgba(248, 248, 248, 1);
    border-radius: 60rpx 60rpx 60rpx 60rpx;
    width: 299rpx;
    height: 110rpx;
    color: var(--benbenFontColor0);
    font-size: 32rpx;
  }

  .information_fd1_2_c0_c0 {
    width: 56rpx;
    height: 56rpx;
  }

  .information_fd1_2_c0 {
    background: linear-gradient(180deg, #176BE8 0%, #5A5CFC 100%);
    border-radius: 60rpx 60rpx 60rpx 60rpx;
    width: 299rpx;
    height: 110rpx;
    color: #FFFFFF;
    font-size: 32rpx;
  }

  .information_fd1_2 {
    width: 638rpx;
  }

  .information_fd1_1_c1 {
    width: 64rpx;
    height: 64rpx;
    position: absolute;
    bottom: 0rpx;
    right: 0rpx;
  }

  .information_fd1_1_c0 {
    width: 200rpx;
    height: 200rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
  }

  .information_fd1_1 {
    width: 200rpx;
    height: 200rpx;
    position: relative;
    margin: 88rpx 0rpx 96rpx 0rpx;
  }

  .information_fd1_0 {
    font-size: 48rpx;
    font-weight: 600;
  }

  .information_picker2_0_c2 {
    color: #4781f5;
  }

  .information_picker2_0 {
    border-bottom: 1px solid #eee;
    background: #fff;
    padding: 0rpx 32rpx 0rpx 32rpx;
    line-height: 88rpx;
    border-radius: 25rpx 25rpx 0rpx 0rpx;
    background-size: 100% auto !important;
  }

  .information_flex_3 {
    width: 750rpx;
    height: 200rpx;
    overflow: hidden;
    z-index: 10;
    bottom: calc(0rpx + var(--window-bottom));
    left: 0rpx;
  }

  .information_fd3_0 {
    background: linear-gradient(180deg, #176BE8 0%, #5A5CFC 100%);
    border-radius: 40rpx 40rpx 40rpx 40rpx;
    width: 638rpx;
    line-height: 80rpx;
    font-size: 32rpx;
    color: #fff;
    height: 80rpx;
    margin: 0rpx auto 0rpx auto;
  }
</style>
